#pragma once
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;

namespace basic_vector
{
	template<class T>
	class vector
	{
	public:
		typedef T* iteratior;

		vector()
		{
			_start = _finish = _end_of_storage = nullptr;
		}

		size_t size()
		{
			return _finish - _start;
		}

		size_t capacity()
		{
			return _end_of_storage - _start;
		}

		void reserve(size_t t)
		{
			if (t > capacity())
			{
				iteratior _newstart = new T[t];
				iteratior _newfinish = _newstart;
				for (iteratior it = _start; it != _finish; ++it)
				{
					++_newfinish;
					*(_newfinish - 1) = *it;
				}
				delete[] _start;
				_start = _newstart;
				_finish = _newfinish;
				_end_of_storage = _newstart + t;
			}
		}

		void push_back(const T& x)
		{
			if (_finish == _end_of_storage)
			{
				size_t newcapacity = capacity() == 0 ? 1 : capacity() * 2;
				reserve(newcapacity);
			} 
			++_finish;
			*(_finish - 1) = x;
		}


	private:
		//T* _a;
		//size_t _size;
		//size_t _capacity; 
		iteratior _start;
		iteratior _finish;
		iteratior _end_of_storage;
	};
}